package com.qys.livesMall.financial.controller.sys;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qys.livesMall.common.result.R;
import com.qys.livesMall.financial.model.dto.sys.OfflineShortVideoAuditDTO;
import com.qys.livesMall.financial.model.dto.sys.OfflineShortVideoQueryDTO;
import com.qys.livesMall.financial.model.dto.sys.OfflineShortVideoSaveDTO;
import com.qys.livesMall.financial.model.vo.sys.OfflineShortVideoVO;
import com.qys.livesMall.financial.service.OfflineShortVideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 理财视频 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-07-31
 */
@RestController
@RequestMapping("/sys/offlineShortVideo")
@Tag(name = "SYS-用户线下理财信息")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysOfflineShortVideoController {

    private final OfflineShortVideoService offlineShortVideoService;

    @PostMapping("/page")
    @Operation(summary = "分页查询短视频信息")
    public R<Page<OfflineShortVideoVO>> pageBySystem(@RequestBody OfflineShortVideoQueryDTO offlineShortVideoQueryDTO) {
        return R.ok(offlineShortVideoService.pageBySystem(offlineShortVideoQueryDTO));
    }

    @PostMapping("/add")
    @Operation(summary = "新增短视频信息")
    public R<Void> insertVideo(@RequestBody @Validated OfflineShortVideoSaveDTO videoSaveDTO) {
        offlineShortVideoService.saveVideoBySystem(videoSaveDTO);
        return R.ok();
    }

    @PutMapping("/edit")
    @Operation(summary = "修改短视频信息")
    public R<Void> editVideo(@RequestBody @Validated OfflineShortVideoSaveDTO videoSaveDTO) {
        offlineShortVideoService.saveVideoBySystem(videoSaveDTO);
        return R.ok();
    }

    @DeleteMapping("/remove")
    @Operation(summary = "根据id删除短视频信息")
    public R<Void> removeById(@RequestBody @Validated OfflineShortVideoAuditDTO auditDTO) {
        offlineShortVideoService.removeByIds(auditDTO.getIds());
        return R.ok();
    }
}
